<template>
    <el-select :disabled="pri_disabled" v-model="privite_val" ref="sgSelectRef" :placeholder="pri_placeholder" clearable filterable :loading="loadData" @change="selChange" :multiple="pri_multiple" class="select100">
        <el-option v-for="item in options" :key="item.value" :label="item.text" :value="item.value">
        </el-option>
    </el-select>
</template>

<script>
import { getList } from "@/api/system/dicItem";

// 字典下拉单选
export default {
    props: {
        value: String,
        typeCode: String,
        placeholder:String,
        multiple:String,
        disabled:Boolean
    },
    async created() {
        this.pri_multiple = this.multiple?this.multiple=='true'?true:false:false
        this.pri_placeholder = this.placeholder??"请选择"
        this.pri_disabled = this.disabled ?? false
        let res = await getList(this.typeCode)
        if (res.code == 10000) {
            this.options = res.data
            this.loadData = false
        }
    },
    data() {
        return {
            pri_placeholder:'',
            pri_multiple:false,
            privite_val: this.value,
            pri_disabled:false,
            options: [

            ],
            loadData: true
        }
    },
    watch: {
        privite_val(val) {
            this.$emit('input', val)
        }
    },
    methods:{
        selChange(val){
            this.$emit('change',val)
        },
        getLabel(){
            return this.$refs.sgSelectRef.selected.label
        }
    }
}
</script>
